local M = {}
M.__index = M

function M.new(obj)
    -- if not obj then
    --     obj = {}
    --     obj.scene_info = {
    --         scene_id = 0,
    --         scene_gid = 0,
    --         position = {
    --             x = 0,
    --             y = 0,
    --             direction = 0
    --         }
    --     }
    --     obj.fight_info = {
    --         atk = 0,
    --         def = 0,
    --         max_hp = 0,
    --         cur_hp = 0,
    --         max_mp = 0,
    --         cur_mp = 0,
    --         speed = 0,
    --         critical_rate = 0,
    --         critical_damage = 0,
    --         evasion_rate = 0,
    --         hit_rate = 0,
    --     }   
    -- end
    obj = obj or {}

    return setmetatable(obj, M)
end


function M:set_scene_id(scene_id)
    self.scene_info.scene_id = scene_id
end

function M:set_scene_gid(scene_gid)
    self.scene_info.scene_gid = scene_gid
end

function M:set_position(position)
    self.scene_info.position = position
end

function M:set_fight_info(fight_info)
    self.fight_info = fight_info
end

function M:set_scene_info(scene_info)
    self.scene_info = scene_info
end

function M:get_scene_id()
    local scene_info = self:get_scene_info()
    return scene_info.scene_id
end

function M:get_scene_gid()
    local scene_info = self:get_scene_info()
    return scene_info.scene_gid
end

function M:get_scene_node()
    local scene_info = self:get_scene_info()
    return scene_info.scene_node
end

function M:get_position()
    local scene_info = self:get_scene_info()
    if not scene_info.position then
        self.scene_info.position = {
            x = 0,
            y = 0,
            direction = 0
        }
    end

    return self.scene_info.position
end

function M:set_direction(direction)
    local scene_info = self:get_scene_info()
    if not scene_info.position then
        self.scene_info.position = {
            x = 0,
            y = 0,
            direction = direction
        }
    else
        scene_info.position.direction = direction
    end
end

function M:get_direction()
    local position = M:get_position()
    return position.direction
end

function M:set_auto_moving()
    self.auto_moving = true
end

function M:remove_auto_moving()
    self.auto_moving = false
end

function M:is_auto_moving()
    return self.auto_moving == true
end

function M:get_fight_info()
    if not self.fight_info then
        self.fight_info = {
            atk = 0,
            def = 0,
            max_hp = 0,
            cur_hp = 0,
            max_mp = 0,
            cur_mp = 0,
            speed = 0,
            critical_rate = 0,
            critical_damage = 0,
            evasion_rate = 0,
            hit_rate = 0,
        }
    end

    return self.fight_info
end

function M:get_scene_info()
    if not self.scene_info then
        self.scene_info = {
            scene_id = 0,
            scene_gid = 0,
            scene_node = 0,
            position = {
                x = 0,
                y = 0,
                direction = 0
            }
        }
    end

    return self.scene_info
end

function M:set_aoi_obj(aoi_obj)
    self.aoi_obj = aoi_obj
end

function M:get_aoi_obj()
    return self.aoi_obj
end

function M:set_speed(speed_x, speed_y)
    self.speed_x = speed_x or 10
    self.speed_y = speed_y or 10
end

function M:get_speed()
    return self.speed_x, self.speed_y
end


return M